<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>大整数相加</title>
</head>
<body>
<script>
    var a="1563312";
    var b="85522";
    function add(a,b){
        var result=[];
        var arr=a.split("");
        var arr1=b.split("");
        if(arr.length>arr1.length){
            for(var i=arr1.length;i<arr.length;i++){
                arr1[i]=0;
                result[i]=0;
            }
        }else{
            for(var i=arr.length;i<arr1.length;i++){
                arr[i]=0;
                result[i]=0;
            }
        }
        for(var i=0;i<arr.length;i++){
           result[i]=0;
        }
        for(var i=0;i<arr.length;i++){
            var c=(Number(arr[i])+Number(arr1[i])+Number(result[i]));
            if(c>=10){
                result[i]=c%10;
                result[i+1]=1;
            }else {
                result[i] = c;
            }
        }
        return result.reverse();
    }
    console.log(add(a,b));


</script>
</body>
</html>